#pragma once

#include "..\\..\\headers.default.h"
#include "..\\..\\headers.classification.h"
#include "..\\..\\headers.ipfe.h"

#include "ClassInfo.h"
#include "FileManager.h"

namespace image_parse
{

	class CPixelSetTools
	{
	public:
		class CLabeledPixel
		{
		public:
			int x, y, FileIndex, Label;

		public:
			static bool Compare_byFileIndex(const CPixelSetTools::CLabeledPixel& a, const CPixelSetTools::CLabeledPixel& b);
			bool InputFromStream(istream& inStream);
			void OutputToStream(ostream& outStream) const;
		};
	public:
		static int GenerateFullPixelList(
			CSimpleTypeArray<CPixelSetTools::CLabeledPixel>& DstPixelList,
			const CFileEntity& FileEntity, int FileIndex,
			bool fClearBeforePushback);
		static int GenerateRandomPixelList(
			CSimpleTypeArray<CPixelSetTools::CLabeledPixel>& DstPixelList,
			const CFileEntity& FileEntity, int FileIndex,
			int PixelMargin, double PixelSampleRate,
			bool fClearBeforePushback);

		static int InputPixelListFromFile(CSimpleTypeArray<CLabeledPixel>& DstPixelList, string strFN_SrcData);
		static void OutputPixelListToFile(string strFN_DstData, const CSimpleTypeArray<CLabeledPixel>& SrcPixelList);
	};

	class CPattern
	{
	public:
		int xL, yL, xH, yH;//, Mode;

	public:
		bool InputFromStream(istream& inStream);
		void OutputToStream(ostream& outStream) const;
	};

	class CPatternSet
	{
	public:
		CSimpleTypeArray<CPattern> PatternList;

	public:
		void myInit(string strFN_PatternConfiguration);
	};

	class CTempTRSsetting
	{
	public:
		bool fDo;
		bool fTile;
		double Angle;
		double xScale;
		double yScale;
	};

	class CDataSet_ImageParse_ByImage : public CLabeledDataSetForClassification
	{
	public:
		CImagePositionFeatureExtractor* _pIPFE;

		string strFN_Pfx_ImageCacheHashName;

		const CFileList* _pFileList;
		const CClassInfoSet* _pClassSet;
		int _LastFileIndex;

		//const CTempTRSsetting* _p_trs_setting;
		//C_TRSable_Image::CParameters _trs_config;

	public:
		CSimpleTypeArray<CPixelSetTools::CLabeledPixel> PixelList;

	public:
		CDataSet_ImageParse_ByImage()
		{
			_pIPFE = NULL;
		}
		~CDataSet_ImageParse_ByImage()
		{
			CDataStructureTools::MyRelease_Single(_pIPFE);
		}
		void InitIPFE(CImageFilterBank* pFixIFB);
		void InitPixelList(string strFN_PixelList, string strFN_Pfx_ImageCacheHashName, const CFileList* pFileList, const CClassInfoSet* pClassSet);

		int GetFeatureDimention();
		int GetNodeAmount();
		int GetNodeLabel(int NodeIndex);
		double GetNodeInitialWeight(int NodeIndex);
		double GetNodeFeature(int NodeIndex, int FeatureIndex);
	};

}

